package IntermediaryPattern;

import java.util.HashMap;

public class PostOfficeImpl implements PostOffice{
    private HashMap villagerMap= new HashMap<String,Villager>();
    @Override
    public void deliverLetters(String letters, String receiver) {
        System.out.println("=>收信：邮局收到要寄的信");
        Villager villager=(Villager)villagerMap.get(receiver);
        System.out.println("=>送信：收信人地址是："+villager.getAddress());
        System.out.println("=>收信人看信");
        villager.receiverLetter(letters);
    }

    @Override
    public void addPeople(Villager villager) {
            villagerMap.put(villager.getClass().getSimpleName(),villager);
    }
}
